home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 1 (Walnut Creek)
/
Aminet - June 1993 [Walnut Creek].iso
/
usenet
/
sources
/
volume91
/
utilitys
/
names_11
/
part01
/
names.c
next >
Wrap
C/C++ Source or Header
|
1991-05-18
|
2KB
|
80 lines
/*
Names v1.1 by Russell Wallace 29 July 1989
Program to generate random names
Useful for generating names for stuff like computer games and so on when you
can't be bothered thinking them up yourself. At the moment it avoids runs of
more than 2 vowels or 2 consonants in a row and generates words of between
3 and 10 letters ... many of the names are unusable, select the usable ones.
I decided this was easier than trying to improve the generation process.
*/
#define videornd (*((unsigned *)0xdff006))
long RangeRand ();
char buffer[11];
main (argc,argv)
char **argv;
{
int i,j,l,NAMES=50;
char c,c1,c2;
if (argc>1)
{
if (!strcmp (argv[1],"?"))
{
printf ("Names v1.1 by Russell Wallace 29 July 1989\n\
Generates random names for fantasy games etc.\n\
Usage: NAMES [number of names to generate]\n");
return;
}
NAMES=atoi (argv[1]);
}
for (j=0;j<NAMES;j++)
{
l=rnd (7)+3;
for (i=0;i<l;i++)
{
if (i<=1)
buffer[i]=rnd (26)+'a';
else
{
c1=buffer[i-1];
c2=buffer[i-2];
do
{
if (rnd (50)==0)
{
if (rnd (2))
c='-';
else
c='\'';
}
else
c=rnd (26)+'a';
}
while (
(!isvowel (c1) && !isvowel (c2) && !isvowel (c)) ||
(isvowel (c1) && isvowel (c2) && isvowel (c))
);
buffer[i]=c;
}
}
buffer[i]=0;
printf ("%s\n",buffer);
}
}
int isvowel (c)
char c;
{
return (c=='a' || c=='e' || c=='i' || c=='o' || c=='u');
}
rnd (x)
{
RangeRand ((long)videornd);
return RangeRand ((long)x);
}